package com.soushin.mvpdemo.module.rxjava.example;

import android.content.Context;
import android.text.method.ScrollingMovementMethod;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import butterknife.BindView;
import butterknife.OnClick;
import com.soushin.mvpdemo.R;
import com.soushin.mvpdemo.base.BaseActivity;

/**
 * Rxjava示例
 *
 * @author SouShin
 * @time 2018/11/16 16:10
 */
public class ExampleActivity extends BaseActivity<ExampleView, ExamplePresenter> implements ExampleView {

    @BindView(R.id.tv_content)
    TextView tvContent;
    @BindView(R.id.btn_do_something)
    Button btnDoSomething;

    @Override
    protected ExamplePresenter createPresenter() {
        return new ExamplePresenter();
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_example;
    }

    @Override
    protected void bindView() {
        getPresenter().subscribe(this);
    }

    @Override
    public void initView() {
        tvContent.setMovementMethod(ScrollingMovementMethod.getInstance());
    }

    @OnClick({R.id.btn_do_something})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_do_something:
                getPresenter().doSomeThing();
                break;
        }
    }

    @Override
    public int getClickPosition() {
        return getIntent().getIntExtra("position", 0);
    }

    @Override
    public void setResult(String result) {
        tvContent.setText(result);
    }

    @Override
    public TextView getResultTextView() {
        return tvContent;
    }

    @Override
    public Context getContext() {
        return getActivity();
    }


}
